package org.jmh.auth.service.impl;

import org.jmh.auth.domain.Role;
import org.jmh.auth.dto.RoleDTO;
import org.jmh.auth.mapper.RoleMapper;
import org.jmh.auth.service.IRoleService;
import org.jmh.base.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lingfeng
 * @since 2024-05-15
 */
@Service
public class RoleServiceImpl extends BaseServiceImpl<Role> implements IRoleService {
    @Autowired
    private RoleMapper mapper;

    @Override
    public List<Long> queryPermissionById(Long id) {
        return mapper.queryPermissionById(id);
    }

    @Override
    public List<Long> queryMenuById(Long id) {
        return mapper.queryMenuById(id);
    }

    @Override
    public void auth(RoleDTO roleDTO) {
        //清空该角色之前的属性
        mapper.deleteAuth(roleDTO.getId());
        //保存新的权限
        mapper.auth(roleDTO);
    }

    @Override
    public void auth1(RoleDTO roleDTO) {
        mapper.deleteAuth1(roleDTO.getId());
        mapper.auth1(roleDTO);
    }
}
